import 'dart:convert' show json;

T asT<T>(dynamic value) {
  if (value is T) {
    return value;
  }
  return null;
}

class FileLoxen {
  FileLoxen(
      {this.id,
      this.cover,
      this.name,
      this.num,
      this.canEdit,
      this.isHide,
      this.myHide});

  factory FileLoxen.fromJson(Map<String, dynamic> jsonRes) => jsonRes == null
      ? null
      : FileLoxen(
          id: asT<int>(jsonRes['id']),
          cover: asT<String>(jsonRes['cover']),
          name: asT<String>(jsonRes['name']),
          num: asT<int>(jsonRes['num']),
          canEdit: asT<int>(jsonRes['can_edit']),
          isHide: asT<bool>(jsonRes['is_hide']),
          myHide: asT<bool>(jsonRes['is_hide']),
        );

  int id;
  String cover;
  String name;
  int num;
  int canEdit;
  int select = 0;
  bool isHide;
  bool myHide;

  Map<String, dynamic> toJson() => <String, dynamic>{
        'id': id,
        'cover': cover,
        'name': name,
        'num': num,
        'can_edit': canEdit,
      };

  @override
  String toString() {
    return json.encode(this);
  }
}
